package com.example.administrator.helloword.ui;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.example.administrator.helloword.R;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {


    private Button btnStartService,btnStopService,btnBindService ,btnUnbindService;


    private TextView textView;
    private TextView passwordView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btnStartService  = findViewById(R.id.btnStartService);
        btnStopService   = findViewById(R.id.btnStopService);
        btnBindService   = findViewById(R.id.btnBindService);
        btnUnbindService = findViewById(R.id.btnUnbindService);

        btnStartService.setOnClickListener(this);
        btnStopService.setOnClickListener(this);
        btnBindService.setOnClickListener(this);
        btnUnbindService.setOnClickListener(this);

        String name = getIntent().getStringExtra("name");
        String pass = getIntent().getStringExtra("pass");

        textView = findViewById(R.id.username);
        passwordView = findViewById(R.id.password);
        textView.setText(name);
        passwordView.setText(pass);

        Log.e("1","onCreate");
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.e("1","onStart");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.e("1","onRestart ");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.e("1","onPause");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.e("1","onResume");
    }



    @Override
    protected void onStop() {
        super.onStop();
        Log.e("1","onStop");
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e("1","onDestroy");
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btnStartService:
                Toast.makeText(this,"btnStartService",Toast.LENGTH_LONG).show();
                Intent intent = new Intent(this,IndexActivity.class);
                startActivity(intent);
                break;
            case R.id.btnStopService:
                Toast.makeText(this,"btnStopService",Toast.LENGTH_LONG);
            case R.id.btnBindService:
                startActivity(new Intent(this,LoginActivity.class));
                break;
            case R.id.btnUnbindService:
                Toast.makeText(this,"btnUnbindService",Toast.LENGTH_LONG);
                break;
        }
    }
}
